package com.nattakute.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nattakute.dao.UserDAO;
import com.nattakute.model.Users;
import com.nattakute.service.UserService;

@Service("userService")
@Transactional
public class UserServicesImpl implements UserService {

	@Autowired
	private UserDAO userDAO;
	
	public List<Users> getAll() {
		// TODO Auto-generated method stub
		return userDAO.getAll();
	}
	
	public Users findByUserId(Integer userId) {
		// TODO Auto-generated method stub
		return userDAO.findByUserId(userId);
	}
	
	@Transactional
	public Boolean insert(Users user) {
		// TODO Auto-generated method stub
		return userDAO.insert(user);
	}

	@Transactional
	public Boolean update(Users user) {
		// TODO Auto-generated method stub
		return userDAO.update(user);
	}

	@Transactional
	public Boolean delete(Users user) {
		// TODO Auto-generated method stub
		return userDAO.delete(user);
	}
	
	@Transactional
	public Boolean deleteUserById(Integer id) {
		// TODO Auto-generated method stub
		return userDAO.deleteUserById(id);
	}

	@Transactional
	public Users userLogin(String userName, String passwod) {
		// TODO Auto-generated method stub
		return userDAO.userLogin(userName, passwod);
	}

	@Transactional
	public Users adminLogin(String userName, String passwod) {
		// TODO Auto-generated method stub
		return userDAO.adminLogin(userName, passwod);
	}
	
	@Transactional
	public List<Users> notActive() {
		// TODO Auto-generated method stub
		return userDAO.notActive();
	}

	@Transactional
	public Boolean activeUser(Users user) {
		// TODO Auto-generated method stub
		return userDAO.activeUser(user);
	}

	@Transactional
	public List<Users> getUserNotAdmin() {
		// TODO Auto-generated method stub
		return userDAO.getUserNotAdmin();
	}

	@Transactional(readOnly=true)
	public Users getUserByName(String userName) {
		return userDAO.getUserByName(userName);
	}

	@Transactional
	public List<Users> getInstructor() {
		return userDAO.getInstructor();
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	
}
